/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author stumbledog
 */
@Entity
@Table(name = "fantasyleague")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fantasyleague.findAll", query = "SELECT f FROM Fantasyleague f"),
    @NamedQuery(name = "Fantasyleague.findById", query = "SELECT f FROM Fantasyleague f WHERE f.id = :id"),
    @NamedQuery(name = "Fantasyleague.findByMaximumNumberOfUsers", query = "SELECT f FROM Fantasyleague f WHERE f.maximumNumberOfUsers = :maximumNumberOfUsers"),
    @NamedQuery(name = "Fantasyleague.findByCurrentNumberOfUsers", query = "SELECT f FROM Fantasyleague f WHERE f.currentNumberOfUsers = :currentNumberOfUsers"),
    @NamedQuery(name = "Fantasyleague.findByLeagueName", query = "SELECT f FROM Fantasyleague f WHERE f.leagueName = :leagueName"),
    @NamedQuery(name = "Fantasyleague.findByLeagueNote", query = "SELECT f FROM Fantasyleague f WHERE f.leagueNote = :leagueNote"),
    @NamedQuery(name = "Fantasyleague.findByDraftDate", query = "SELECT f FROM Fantasyleague f WHERE f.draftDate = :draftDate")})
public class Fantasyleague implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "maximumNumberOfUsers")
    private int maximumNumberOfUsers;
    @Basic(optional = false)
    @NotNull
    @Column(name = "currentNumberOfUsers")
    private int currentNumberOfUsers;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "leagueName")
    private String leagueName;
    @Size(max = 45)
    @Column(name = "leagueNote")
    private String leagueNote;
    @Basic(optional = false)
    @NotNull
    @Column(name = "draftDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date draftDate;
    @JoinColumn(name = "ownerUserId", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Fantasyuser ownerUserId;
    @OneToMany(mappedBy = "leagueId")
    private Collection<Fantasymatch> fantasymatchCollection;
    @OneToMany(mappedBy = "leagueId")
    private Collection<Fantasydiscussion> fantasydiscussionCollection;
    @OneToMany(mappedBy = "leagueId")
    private Collection<Fantasyteam> fantasyteamCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "leagueId")
    private Collection<Fantasydraftresult> fantasydraftresultCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "fantasyleague")
    private Fantasyplayoff fantasyplayoff;

    public Fantasyleague() {
    }

    public Fantasyleague(Integer id) {
        this.id = id;
    }

    public Fantasyleague(Integer id, int maximumNumberOfUsers, int currentNumberOfUsers, String leagueName, Date draftDate) {
        this.id = id;
        this.maximumNumberOfUsers = maximumNumberOfUsers;
        this.currentNumberOfUsers = currentNumberOfUsers;
        this.leagueName = leagueName;
        this.draftDate = draftDate;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getMaximumNumberOfUsers() {
        return maximumNumberOfUsers;
    }

    public void setMaximumNumberOfUsers(int maximumNumberOfUsers) {
        this.maximumNumberOfUsers = maximumNumberOfUsers;
    }

    public int getCurrentNumberOfUsers() {
        return currentNumberOfUsers;
    }

    public void setCurrentNumberOfUsers(int currentNumberOfUsers) {
        this.currentNumberOfUsers = currentNumberOfUsers;
    }

    public String getLeagueName() {
        return leagueName;
    }

    public void setLeagueName(String leagueName) {
        this.leagueName = leagueName;
    }

    public String getLeagueNote() {
        return leagueNote;
    }

    public void setLeagueNote(String leagueNote) {
        this.leagueNote = leagueNote;
    }

    public Date getDraftDate() {
        return draftDate;
    }

    public void setDraftDate(Date draftDate) {
        this.draftDate = draftDate;
    }

    public Fantasyuser getOwnerUserId() {
        return ownerUserId;
    }

    public void setOwnerUserId(Fantasyuser ownerUserId) {
        this.ownerUserId = ownerUserId;
    }

    @XmlTransient
    public Collection<Fantasymatch> getFantasymatchCollection() {
        return fantasymatchCollection;
    }

    public void setFantasymatchCollection(Collection<Fantasymatch> fantasymatchCollection) {
        this.fantasymatchCollection = fantasymatchCollection;
    }

    @XmlTransient
    public Collection<Fantasydiscussion> getFantasydiscussionCollection() {
        return fantasydiscussionCollection;
    }

    public void setFantasydiscussionCollection(Collection<Fantasydiscussion> fantasydiscussionCollection) {
        this.fantasydiscussionCollection = fantasydiscussionCollection;
    }

    @XmlTransient
    public Collection<Fantasyteam> getFantasyteamCollection() {
        return fantasyteamCollection;
    }

    public void setFantasyteamCollection(Collection<Fantasyteam> fantasyteamCollection) {
        this.fantasyteamCollection = fantasyteamCollection;
    }

    @XmlTransient
    public Collection<Fantasydraftresult> getFantasydraftresultCollection() {
        return fantasydraftresultCollection;
    }

    public void setFantasydraftresultCollection(Collection<Fantasydraftresult> fantasydraftresultCollection) {
        this.fantasydraftresultCollection = fantasydraftresultCollection;
    }

    public Fantasyplayoff getFantasyplayoff() {
        return fantasyplayoff;
    }

    public void setFantasyplayoff(Fantasyplayoff fantasyplayoff) {
        this.fantasyplayoff = fantasyplayoff;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fantasyleague)) {
            return false;
        }
        Fantasyleague other = (Fantasyleague) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Fantasyleague[ id=" + id + " ]";
    }
    
}
